/*
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 *
 * Copyright @2008 the original author or authors.
 */
package com.bluestone.report;

import java.beans.PropertyChangeEvent;

/**
 * CommandReportBean records some informations for Command.
 * @author <a href="mailto:ming7655@gmail.com">Aaron</a>
 */
public class CommandReportBean extends AbstractReportBean {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6124178439491289004L;

	private String commandId;

	private String commandName;

	private String commandExecuteResult = "true";

	public String getCommandId() {
		return commandId;
	}

	public void setCommandId(String commandId) {
		this.commandId = commandId;
	}

	public String getCommandName() {
		return commandName;
	}

	public void setCommandName(String commandName) {
		this.commandName = commandName;
	}

	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		super.propertyChange(evt);
		String propertyName = evt.getPropertyName();
		Object value = evt.getNewValue();
		Object source = evt.getSource();
		if (!ActionReportBean.class.isInstance(source)) {
			return;
		}
		if (PropertyAwareObject.PROPERTY_EXECUTERESULT.equals(propertyName)) {
			if ("false".equals(value)) {
				this.setCommandExecuteResult("false");
			}
		} 
	}

	public String getCommandExecuteResult() {
		return commandExecuteResult;
	}

	public void setCommandExecuteResult(String commandExecuteResult) {
		this.commandExecuteResult = commandExecuteResult;
		this.firePropertyChange(PROPERTY_EXECUTERESULT, null,
				this.commandExecuteResult);
	}

}
